# Input - run, runfolder, delta
args=(commandArgs(TRUE))
for(i in 1:length(args)){
    eval(parse(text=args[[i]]))
}	 
data <- read.csv(file=run,header=TRUE)

y.lim.div <- 0.7
pdf(paste(run,".pdf",sep=""),width=8.5,height=11)
sw <- c(1e-06, 1e-07,1e-08)
pp <- c(0,0.5,1)
par(mfrow=c(3,3),mar=c(5,5,3,0.5))
for(i in 1:3){
for(ppi in 1:3){
dd <- data[data["a"]==0&data["p"]==pp[ppi]&data["nu"]==1e-04&data["mu"]==sw[i]&data["b"]==0.02&data["d"]==0.016&data["t"]==14600,]
ddmaxa0 <- dd[dd["max_min"]==1,]
ddmina0 <- dd[dd["max_min"]==-1,]
dd <- data[data["a"]==1&data["p"]==pp[ppi]&data["nu"]==1e-04&data["mu"]==sw[i]&data["b"]==0.02&data["d"]==0.016&data["t"]==14600,]
ddmaxa1 <- dd[dd["max_min"]==1,]
ddmina1 <- dd[dd["max_min"]==-1,]
plot(0,0,xlim=c(-50, 14700),ylim=c(0,y.lim.div),pty="m",t="n",xaxs="r",yaxs="r",xlab="Time (years)",ylab="Divergence",las=1,xaxt="n")
axis(1,at=c(0, 3650, 7300, 10950, 14600),lab=c(0,10,20,30,40))
#title(paste("p=",pp[ppi]," mu=",sw[i]," nu=1e-04 b=0.02 d=0.016",sep=""))
title(paste("p=",pp[ppi]," mu=",sw[i],sep=""))
points(t(ddmaxa0["day"]),t(ddmaxa0["divergence"]),t="p",pch=".",col="black")
points(t(ddmina0["day"]),t(ddmina0["divergence"]),t="p",pch=".",col="black")
points(t(ddmaxa1["day"]),t(ddmaxa1["divergence"]),t="p",pch=".",col="black")
points(t(ddmina1["day"]),t(ddmina1["divergence"]),t="p",pch=".",col="black")
for(repi in 1:5){
dd <- data[data["a"]==0&data["p"]==pp[ppi]&data["nu"]==1e-04&data["mu"]==sw[i]&data["b"]==0.02&data["d"]==0.016&data["t"]==14600&data["rep"]==repi,]
dd <- dd[with(dd,order(day)),]
lines(t(dd["day"]),t(dd["divergence"]),lty=2)
}
for(repi in 1:5){
dd <- data[data["a"]==1&data["p"]==pp[ppi]&data["nu"]==1e-04&data["mu"]==sw[i]&data["b"]==0.02&data["d"]==0.016&data["t"]==14600&data["rep"]==repi,]
dd <- dd[with(dd,order(day)),]
lines(t(dd["day"]),t(dd["divergence"]),lty=1)
}
}
}
dev.off()











